package Converters;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JOptionPane;

public class DateConverter {
    
    String outputDate;
    public boolean flag;
    
    public final String Dateconverter(String inputDate){
        
        String regex = "^(3[01]|[12][0-9]|0[1-9])/(1[0-2]|0[1-9])/[0-9]{4}$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(inputDate);
        if (matcher.matches() == true){
            outputDate = inputDate;
            flag = true;
        }
        else{
            JOptionPane.showMessageDialog(null, "Η Ημερ.Γέννησης πρέπει να έχει την μορφή ΗΗ/ΜΜ/ΕΕΕΕ (π.χ. 23/01/2015)");
            flag = false;
        }
        return outputDate;
    }
    
    public final String Dateconverter2(String inputDate){
        
        String regex = "^(3[01]|[12][0-9]|0[1-9])/(1[0-2]|0[1-9])/[0-9]{4}$";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(inputDate);
        if (matcher.matches() == true){
            outputDate = inputDate;
            flag = true;
        }
        else{            
            flag = false;
        }
        return outputDate;
    }
    
}
